<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: ActiveRecord::Acts::Versioned::ActMethods</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">ActiveRecord::Acts::Versioned::ActMethods</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../../files/vendor/plugins/acts_as_versioned/lib/acts_as_versioned_rb.html">
                vendor/plugins/acts_as_versioned/lib/acts_as_versioned.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000009">changed?</a>&nbsp;&nbsp;
      <a href="#M000019">clear_changed_attributes</a>&nbsp;&nbsp;
      <a href="#M000003">clear_old_versions</a>&nbsp;&nbsp;
      <a href="#M000011">clone_versioned_model</a>&nbsp;&nbsp;
      <a href="#M000010">dirty?</a>&nbsp;&nbsp;
      <a href="#M000016">empty_callback</a>&nbsp;&nbsp;
      <a href="#M000018">next_version</a>&nbsp;&nbsp;
      <a href="#M000004">revert_to</a>&nbsp;&nbsp;
      <a href="#M000005">revert_to!</a>&nbsp;&nbsp;
      <a href="#M000001">save_version</a>&nbsp;&nbsp;
      <a href="#M000012">save_version?</a>&nbsp;&nbsp;
      <a href="#M000002">save_version_on_create</a>&nbsp;&nbsp;
      <a href="#M000006">save_without_revision</a>&nbsp;&nbsp;
      <a href="#M000007">save_without_revision!</a>&nbsp;&nbsp;
      <a href="#M000017">set_new_version</a>&nbsp;&nbsp;
      <a href="#M000013">version_condition_met?</a>&nbsp;&nbsp;
      <a href="#M000008">versioned_attributes</a>&nbsp;&nbsp;
      <a href="#M000015">without_locking</a>&nbsp;&nbsp;
      <a href="#M000014">without_revision</a>&nbsp;&nbsp;
      <a href="#M000020">write_changed_attribute</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">

    <div id="class-list">
      <h3 class="section-bar">Classes and Modules</h3>

      Module <a href="ActMethods/ClassMethods.html" class="link">ActiveRecord::Acts::Versioned::ActMethods::ClassMethods</a><br />

    </div>




      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000009" class="method-detail">
        <a name="M000009"></a>

        <div class="method-heading">
          <a href="#M000009" class="method-signature">
          <span class="method-name">changed?</span><span class="method-args">(attr_name = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
If called with no parameters, gets whether the current model has changed
and needs to be versioned. If called with a single parameter, gets whether
the parameter has changed.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000009-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/acts_as_versioned/lib/acts_as_versioned.rb, line 353</span>
353:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">changed?</span>(<span class="ruby-identifier">attr_name</span> = <span class="ruby-keyword kw">nil</span>)
354:           <span class="ruby-identifier">attr_name</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-value">?
355: </span>            (<span class="ruby-operator">!</span><span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">track_changed_attributes</span> <span class="ruby-operator">||</span> (<span class="ruby-identifier">changed_attributes</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">changed_attributes</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>)) <span class="ruby-operator">:</span>
356:             (<span class="ruby-identifier">changed_attributes</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">changed_attributes</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">attr_name</span>.<span class="ruby-identifier">to_s</span>))
357:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000003" class="method-detail">
        <a name="M000003"></a>

        <div class="method-heading">
          <a href="#M000003" class="method-signature">
          <span class="method-name">clear_old_versions</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Clears old revisions if a limit is set with the :limit option in
<tt>acts_as_versioned</tt>. Override this method to set your own criteria
for clearing old versions.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000003-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/acts_as_versioned/lib/acts_as_versioned.rb, line 303</span>
303:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">clear_old_versions</span>
304:           <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">max_version_limit</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
305:           <span class="ruby-identifier">excess_baggage</span> = <span class="ruby-identifier">send</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">version_column</span>).<span class="ruby-identifier">to_i</span> <span class="ruby-operator">-</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">max_version_limit</span>
306:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">excess_baggage</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
307:             <span class="ruby-identifier">sql</span> = <span class="ruby-node">&quot;DELETE FROM #{self.class.versioned_table_name} WHERE version &lt;= #{excess_baggage} AND #{self.class.versioned_foreign_key} = #{self.id}&quot;</span>
308:             <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">versioned_class</span>.<span class="ruby-identifier">connection</span>.<span class="ruby-identifier">execute</span> <span class="ruby-identifier">sql</span>
309:           <span class="ruby-keyword kw">end</span>
310:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000011" class="method-detail">
        <a name="M000011"></a>

        <div class="method-heading">
          <a href="#M000011" class="method-signature">
          <span class="method-name">clone_versioned_model</span><span class="method-args">(orig_model, new_model)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Clones a model. Used when saving a new version or reverting a model&#8216;s
version.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000011-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/acts_as_versioned/lib/acts_as_versioned.rb, line 363</span>
363:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">clone_versioned_model</span>(<span class="ruby-identifier">orig_model</span>, <span class="ruby-identifier">new_model</span>)
364:           <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">versioned_attributes</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
365:             <span class="ruby-identifier">new_model</span>.<span class="ruby-identifier">send</span>(<span class="ruby-node">&quot;#{key}=&quot;</span>, <span class="ruby-identifier">orig_model</span>.<span class="ruby-identifier">attributes</span>[<span class="ruby-identifier">key</span>]) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">orig_model</span>.<span class="ruby-identifier">has_attribute?</span>(<span class="ruby-identifier">key</span>)
366:           <span class="ruby-keyword kw">end</span>
367:           
368:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">orig_model</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">versioned_class</span>)
369:             <span class="ruby-identifier">new_model</span>[<span class="ruby-identifier">new_model</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">inheritance_column</span>] = <span class="ruby-identifier">orig_model</span>[<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">versioned_inheritance_column</span>]
370:           <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">new_model</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">versioned_class</span>)
371:             <span class="ruby-identifier">new_model</span>[<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">versioned_inheritance_column</span>] = <span class="ruby-identifier">orig_model</span>[<span class="ruby-identifier">orig_model</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">inheritance_column</span>]
372:           <span class="ruby-keyword kw">end</span>
373:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000010" class="method-detail">
        <a name="M000010"></a>

        <div class="method-heading">
          <span class="method-name">dirty?</span><span class="method-args">(attr_name = nil)</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for changed?
</p>
        </div>
      </div>

      <div id="method-M000016" class="method-detail">
        <a name="M000016"></a>

        <div class="method-heading">
          <a href="#M000016" class="method-signature">
          <span class="method-name">empty_callback</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000016-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/acts_as_versioned/lib/acts_as_versioned.rb, line 413</span>
413:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">empty_callback</span>() <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000004" class="method-detail">
        <a name="M000004"></a>

        <div class="method-heading">
          <a href="#M000004" class="method-signature">
          <span class="method-name">revert_to</span><span class="method-args">(version)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Reverts a model to a given version. Takes either a version number or an
instance of the versioned model
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000004-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/acts_as_versioned/lib/acts_as_versioned.rb, line 313</span>
313:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">revert_to</span>(<span class="ruby-identifier">version</span>)
314:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">version</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">versioned_class</span>)
315:             <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">version</span>.<span class="ruby-identifier">send</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">versioned_foreign_key</span>) <span class="ruby-operator">==</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">id</span> <span class="ruby-keyword kw">and</span> <span class="ruby-operator">!</span><span class="ruby-identifier">version</span>.<span class="ruby-identifier">new_record?</span>
316:           <span class="ruby-keyword kw">else</span>
317:             <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">version</span> = <span class="ruby-identifier">versions</span>.<span class="ruby-identifier">find_by_version</span>(<span class="ruby-identifier">version</span>)
318:           <span class="ruby-keyword kw">end</span>
319:           <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">clone_versioned_model</span>(<span class="ruby-identifier">version</span>, <span class="ruby-keyword kw">self</span>)
320:           <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-node">&quot;#{self.class.version_column}=&quot;</span>, <span class="ruby-identifier">version</span>.<span class="ruby-identifier">version</span>)
321:           <span class="ruby-keyword kw">true</span>
322:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000005" class="method-detail">
        <a name="M000005"></a>

        <div class="method-heading">
          <a href="#M000005" class="method-signature">
          <span class="method-name">revert_to!</span><span class="method-args">(version)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Reverts a model to a given version and saves the model. Takes either a
version number or an instance of the versioned model
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000005-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/acts_as_versioned/lib/acts_as_versioned.rb, line 326</span>
326:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">revert_to!</span>(<span class="ruby-identifier">version</span>)
327:           <span class="ruby-identifier">revert_to</span>(<span class="ruby-identifier">version</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">save_without_revision</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">false</span>
328:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000001" class="method-detail">
        <a name="M000001"></a>

        <div class="method-heading">
          <a href="#M000001" class="method-signature">
          <span class="method-name">save_version</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Saves a version of the model if applicable
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000001-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/acts_as_versioned/lib/acts_as_versioned.rb, line 288</span>
288:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">save_version</span>
289:           <span class="ruby-identifier">save_version_on_create</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">save_version?</span>
290:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000012" class="method-detail">
        <a name="M000012"></a>

        <div class="method-heading">
          <a href="#M000012" class="method-signature">
          <span class="method-name">save_version?</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Checks whether a new version shall be saved or not. Calls <tt><a
href="ActMethods.html#M000013">version_condition_met?</a></tt> and <tt><a
href="ActMethods.html#M000009">changed?</a></tt>.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000012-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/acts_as_versioned/lib/acts_as_versioned.rb, line 376</span>
376:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">save_version?</span>
377:           <span class="ruby-identifier">version_condition_met?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">changed?</span>
378:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000002" class="method-detail">
        <a name="M000002"></a>

        <div class="method-heading">
          <a href="#M000002" class="method-signature">
          <span class="method-name">save_version_on_create</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Saves a version of the model in the versioned table. This is called in the
after_save callback by default
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000002-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/acts_as_versioned/lib/acts_as_versioned.rb, line 293</span>
293:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">save_version_on_create</span>
294:           <span class="ruby-identifier">rev</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">versioned_class</span>.<span class="ruby-identifier">new</span>
295:           <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">clone_versioned_model</span>(<span class="ruby-keyword kw">self</span>, <span class="ruby-identifier">rev</span>)
296:           <span class="ruby-identifier">rev</span>.<span class="ruby-identifier">version</span> = <span class="ruby-identifier">send</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">version_column</span>)
297:           <span class="ruby-identifier">rev</span>.<span class="ruby-identifier">send</span>(<span class="ruby-node">&quot;#{self.class.versioned_foreign_key}=&quot;</span>, <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">id</span>)
298:           <span class="ruby-identifier">rev</span>.<span class="ruby-identifier">save</span>
299:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000006" class="method-detail">
        <a name="M000006"></a>

        <div class="method-heading">
          <a href="#M000006" class="method-signature">
          <span class="method-name">save_without_revision</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Temporarily turns off Optimistic Locking while saving. Used when reverting
so that a new version is not created.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000006-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/acts_as_versioned/lib/acts_as_versioned.rb, line 331</span>
331:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">save_without_revision</span>
332:           <span class="ruby-identifier">save_without_revision!</span>
333:           <span class="ruby-keyword kw">true</span>
334:         <span class="ruby-keyword kw">rescue</span>
335:           <span class="ruby-keyword kw">false</span>
336:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000007" class="method-detail">
        <a name="M000007"></a>

        <div class="method-heading">
          <a href="#M000007" class="method-signature">
          <span class="method-name">save_without_revision!</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000007-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/acts_as_versioned/lib/acts_as_versioned.rb, line 338</span>
338:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">save_without_revision!</span>
339:           <span class="ruby-identifier">without_locking</span> <span class="ruby-keyword kw">do</span>
340:             <span class="ruby-identifier">without_revision</span> <span class="ruby-keyword kw">do</span>
341:               <span class="ruby-identifier">save!</span>
342:             <span class="ruby-keyword kw">end</span>
343:           <span class="ruby-keyword kw">end</span>
344:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000013" class="method-detail">
        <a name="M000013"></a>

        <div class="method-heading">
          <a href="#M000013" class="method-signature">
          <span class="method-name">version_condition_met?</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Checks condition set in the :if option to check whether a revision should
be created or not. Override this for custom version condition checking.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000013-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/acts_as_versioned/lib/acts_as_versioned.rb, line 382</span>
382:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">version_condition_met?</span>
383:           <span class="ruby-keyword kw">case</span>
384:           <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">version_condition</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Symbol</span>)
385:             <span class="ruby-identifier">send</span>(<span class="ruby-identifier">version_condition</span>)
386:           <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">version_condition</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:call</span>) <span class="ruby-operator">&amp;&amp;</span> (<span class="ruby-identifier">version_condition</span>.<span class="ruby-identifier">arity</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">version_condition</span>.<span class="ruby-identifier">arity</span> <span class="ruby-operator">==</span> <span class="ruby-value">-1</span>)
387:             <span class="ruby-identifier">version_condition</span>.<span class="ruby-identifier">call</span>(<span class="ruby-keyword kw">self</span>)
388:           <span class="ruby-keyword kw">else</span>
389:             <span class="ruby-identifier">version_condition</span>
390:           <span class="ruby-keyword kw">end</span>          
391:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000008" class="method-detail">
        <a name="M000008"></a>

        <div class="method-heading">
          <a href="#M000008" class="method-signature">
          <span class="method-name">versioned_attributes</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns an array of attribute keys that are versioned. See
non_versioned_columns
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000008-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/acts_as_versioned/lib/acts_as_versioned.rb, line 347</span>
347:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">versioned_attributes</span>
348:           <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">attributes</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">select</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-operator">!</span><span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">non_versioned_columns</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">k</span>) }
349:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000015" class="method-detail">
        <a name="M000015"></a>

        <div class="method-heading">
          <a href="#M000015" class="method-signature">
          <span class="method-name">without_locking</span><span class="method-args">(&amp;block)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Turns off optimistic locking for the duration of the block
</p>
<pre>
  @foo.without_locking do
    @foo.save
  end
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000015-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/acts_as_versioned/lib/acts_as_versioned.rb, line 409</span>
409:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">without_locking</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
410:           <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">without_locking</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
411:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000014" class="method-detail">
        <a name="M000014"></a>

        <div class="method-heading">
          <a href="#M000014" class="method-signature">
          <span class="method-name">without_revision</span><span class="method-args">(&amp;block)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Executes the block with the versioning callbacks disabled.
</p>
<pre>
  @foo.without_revision do
    @foo.save
  end
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000014-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/acts_as_versioned/lib/acts_as_versioned.rb, line 399</span>
399:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">without_revision</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
400:           <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">without_revision</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
401:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Protected Instance methods</h3>

      <div id="method-M000019" class="method-detail">
        <a name="M000019"></a>

        <div class="method-heading">
          <a href="#M000019" class="method-signature">
          <span class="method-name">clear_changed_attributes</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
clears current changed attributes. Called after save.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000019-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000019-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/acts_as_versioned/lib/acts_as_versioned.rb, line 428</span>
428:           <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">clear_changed_attributes</span>
429:             <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">changed_attributes</span> = []
430:           <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000018" class="method-detail">
        <a name="M000018"></a>

        <div class="method-heading">
          <a href="#M000018" class="method-signature">
          <span class="method-name">next_version</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Gets the next available version for the current record, or 1 for a new
record
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000018-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/acts_as_versioned/lib/acts_as_versioned.rb, line 422</span>
422:           <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">next_version</span>
423:             <span class="ruby-keyword kw">return</span> <span class="ruby-value">1</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">new_record?</span>
424:             (<span class="ruby-identifier">versions</span>.<span class="ruby-identifier">calculate</span>(<span class="ruby-identifier">:max</span>, <span class="ruby-identifier">:version</span>) <span class="ruby-operator">||</span> <span class="ruby-value">0</span>) <span class="ruby-operator">+</span> <span class="ruby-value">1</span>
425:           <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000017" class="method-detail">
        <a name="M000017"></a>

        <div class="method-heading">
          <a href="#M000017" class="method-signature">
          <span class="method-name">set_new_version</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
sets the new version before saving, unless you&#8216;re using optimistic
locking. In that case, let it take care of the version.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000017-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/acts_as_versioned/lib/acts_as_versioned.rb, line 417</span>
417:           <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_new_version</span>
418:             <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-node">&quot;#{self.class.version_column}=&quot;</span>, <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">next_version</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">new_record?</span> <span class="ruby-operator">||</span> (<span class="ruby-operator">!</span><span class="ruby-identifier">locking_enabled?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">save_version?</span>)
419:           <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000020" class="method-detail">
        <a name="M000020"></a>

        <div class="method-heading">
          <a href="#M000020" class="method-signature">
          <span class="method-name">write_changed_attribute</span><span class="method-args">(attr_name, attr_value)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000020-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000020-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/acts_as_versioned/lib/acts_as_versioned.rb, line 432</span>
432:           <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">write_changed_attribute</span>(<span class="ruby-identifier">attr_name</span>, <span class="ruby-identifier">attr_value</span>)
433:             <span class="ruby-comment cmt"># Convert to db type for comparison. Avoids failing Float&lt;=&gt;String comparisons.</span>
434:             <span class="ruby-identifier">attr_value_for_db</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">columns_hash</span>[<span class="ruby-identifier">attr_name</span>.<span class="ruby-identifier">to_s</span>].<span class="ruby-identifier">type_cast</span>(<span class="ruby-identifier">attr_value</span>)
435:             (<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">changed_attributes</span> <span class="ruby-operator">||=</span> []) <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">attr_name</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">changed?</span>(<span class="ruby-identifier">attr_name</span>) <span class="ruby-operator">||</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">attr_name</span>) <span class="ruby-operator">==</span> <span class="ruby-identifier">attr_value_for_db</span>
436:             <span class="ruby-identifier">write_attribute</span>(<span class="ruby-identifier">attr_name</span>, <span class="ruby-identifier">attr_value_for_db</span>)
437:           <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>